#pragma once

#include <QtGui/QWidget>




namespace Engine
{
	namespace Edit
	{
		/**
		 * This widget offers a similar functionality to the Visual Studio Text Editor:
		 * - line numbers
		 * - setting breakpoints
		 */
		class NumberWidget
			: public QWidget
		{
			Q_OBJECT

		public:

			NumberWidget(QWidget* parent);
			virtual ~NumberWidget();



			void setHasBreakpoints(bool enabled);



			void setCurrentLine(int lineno);

			void addBreakpoint(int line);
			void removeBreakpoint(int line);

			void setBugLine(int lineno);

			void setFont(QFont font);
			void setTextEdit(QTextEdit* edit);

		protected:

			virtual void paintEvent(QPaintEvent*);
			virtual void mouseReleaseEvent(QMouseEvent* event);
			virtual bool event(QEvent *event);

		protected slots:

			void documentChanged();

		private:

			QTextEdit*         edit;

			QFont              m_font;
			QFontMetrics       m_metrics;

			QMap<int, QRect>   m_breakpoints;

			int                currentLine;
			int                bugLine;

			QPixmap            stopMarker;
			QPixmap            currentMarker;
			QPixmap            bugMarker;

			QRect              currentRect;

			bool               m_hasBreakpoints;
		};
		///////////////////////////////////////////////////////////////////////////////////////////
	}
	///////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////
